﻿namespace Huayou.Utils
{
    using System;
    using System.IO;
    using System.Text;

    public class FileUtils
    {
        public static string GetContent(string filename)
        {
            return GetContent(filename, "gb2312");
        }

        public static string GetContent(string filename, string encoding)
        {
            StringBuilder builder = new StringBuilder();
            StreamReader reader = new StreamReader(filename, Encoding.GetEncoding(encoding));
            string str = null;
            while ((str = reader.ReadLine()) != null)
            {
                builder.Append(str + "\r\n");
            }
            reader.Close();
            return builder.ToString();
        }

        public static StringBuilder GetSBContent(string filename, string encoding)
        {
            StringBuilder builder = new StringBuilder();
            StreamReader reader = new StreamReader(filename, Encoding.GetEncoding(encoding));
            string str = null;
            while ((str = reader.ReadLine()) != null)
            {
                builder.Append(str + "\r\n");
            }
            reader.Close();
            return builder;
        }
    }
}

